package com.liang.recommend;

import com.liang.pojo.Movie;
import com.liang.service.impl.MovieServiceImpl;
import com.liang.service.impl.UserActionServiceImpl;

import java.util.ArrayList;
import java.util.List;

public class Recommend2 {
    private int userId;
    private int index;
    private List<Movie> getMovieList;
    private int[] movieId;
    private List<Movie> rdMovieList;
    int temp=0;

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public List<Movie> getRecommendMovie(){
        MovieServiceImpl movieService = new MovieServiceImpl();
        UserActionServiceImpl userActionService = new UserActionServiceImpl();
        getMovieList=movieService.getRdMovieList2(userId,index);
        movieId = userActionService.getMovieIdById(userId);
        rdMovieList=new ArrayList<Movie>();
        //不重复推荐处理
        for (Movie movie : getMovieList) {
            if(temp<movieId.length){
              if(movie.getMovie_id()!=movieId[temp]){
                    rdMovieList.add(movie);
                }
            }else {
                rdMovieList.add(movie);
            }
            temp+=1;
        }
        return rdMovieList;
    }
}
